package demo1;

import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2024-03-09
 * Time: 9:07
 */
public class Test1 {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        for (String s:args){
            if (! isOpera(s)){
                stack.push(Integer.parseInt(s));
            }else {
                int num2 = stack.pop();
                int num1 = stack.pop();
                        switch(s){
                            case"+" :
                                stack.push(num1+num2);
                                break;
                            case"-" :
                                stack.push(num1-num2);
                                break;
                            case"*" :
                                stack.push(num1*num2);
                                break;
                            case"/" :
                                stack.push(num1/num2);
                                break;
                        }
            }

        }

    }
    public static boolean isOpera(String x) {
        if (x.equals("+")|| x.equals("-")||x.equals("*")||x.equals("/")){
            return true;
        }
        return false;
    }
}
